import 'package:app/jspangStudy/page/home.dart';
import 'package:app/jspangStudy/page/email.dart';
import 'package:app/jspangStudy/page/page.dart';
import 'package:app/jspangStudy/page/set.dart';
import 'package:flutter/material.dart';

class NormalNavBar extends StatefulWidget {
  NormalNavBar({Key key}) : super(key: key);

  @override
  _NormalNavBarState createState() => _NormalNavBarState();
}

class _NormalNavBarState extends State<NormalNavBar> {
  final _bottomNavigationColor = Colors.blue;
  int _currentIndex = 0;
  List<Widget> list = List();

  @override
  void initState() {
    list..add(Home())..add(Email())..add(Pages())..add(Set());
    super.initState(); //调用父类初始化方法
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: list[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        onTap: (int value) => {
          setState(() => {_currentIndex = value})
        },
        currentIndex: _currentIndex,
        items: [
          BottomNavigationBarItem(
            icon: Icon(
              Icons.home,
              color: _bottomNavigationColor,
            ),
            title: Text(
              '首页',
              style: TextStyle(
                color: _bottomNavigationColor,
              ),
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.email,
              color: _bottomNavigationColor,
            ),
            title: Text(
              '邮件',
              style: TextStyle(
                color: _bottomNavigationColor,
              ),
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.pages,
              color: _bottomNavigationColor,
            ),
            title: Text(
              '页面',
              style: TextStyle(
                color: _bottomNavigationColor,
              ),
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.settings,
              color: _bottomNavigationColor,
            ),
            title: Text(
              '设置',
              style: TextStyle(
                color: _bottomNavigationColor,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
